home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch5 / HiResPrv.frm (.txt) < prev    next >
Visual Basic Form  |  1999-04-05  |  4KB  |  135 lines

  1. VERSION 5.00
  2. Begin VB.Form frmHiResPrv 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "HiResPrv"
  5.    ClientHeight    =   2250
  6.    ClientLeft      =   510
  7.    ClientTop       =   1290
  8.    ClientWidth     =   2115
  9.    KeyPreview      =   -1  'True
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   2250
  15.    ScaleWidth      =   2115
  16.    ShowInTaskbar   =   0   'False
  17.    Begin VB.PictureBox HiddenPict 
  18.       AutoRedraw      =   -1  'True
  19.       BackColor       =   &H00FFFFFF&
  20.       BorderStyle     =   0  'None
  21.       Height          =   1695
  22.       Left            =   600
  23.       ScaleHeight     =   1695
  24.       ScaleWidth      =   1455
  25.       TabIndex        =   1
  26.       Top             =   480
  27.       Visible         =   0   'False
  28.       Width           =   1455
  29.    End
  30.    Begin VB.PictureBox PreviewPict 
  31.       AutoRedraw      =   -1  'True
  32.       BackColor       =   &H00FFFFFF&
  33.       BorderStyle     =   0  'None
  34.       Height          =   1695
  35.       Left            =   0
  36.       ScaleHeight     =   1695
  37.       ScaleWidth      =   1455
  38.       TabIndex        =   0
  39.       Top             =   0
  40.       Width           =   1455
  41.    End
  42.    Begin VB.Menu mnuFile 
  43.       Caption         =   "&File"
  44.       Begin VB.Menu mnuFileClose 
  45.          Caption         =   "&Close"
  46.       End
  47.    End
  48.    Begin VB.Menu mnuScale 
  49.       Caption         =   "&Scale"
  50.       Begin VB.Menu mnuSetScale 
  51.          Caption         =   "&Large"
  52.          Index           =   0
  53.          Shortcut        =   ^L
  54.       End
  55.       Begin VB.Menu mnuSetScale 
  56.          Caption         =   "&Normal"
  57.          Checked         =   -1  'True
  58.          Index           =   1
  59.          Shortcut        =   ^N
  60.       End
  61.       Begin VB.Menu mnuSetScale 
  62.          Caption         =   "&Small"
  63.          Index           =   2
  64.          Shortcut        =   ^S
  65.       End
  66.    End
  67. Attribute VB_Name = "frmHiResPrv"
  68. Attribute VB_GlobalNameSpace = False
  69. Attribute VB_Creatable = False
  70. Attribute VB_PredeclaredId = True
  71. Attribute VB_Exposed = False
  72. Option Explicit
  73. ' ************************************************
  74. ' Display a preview for this form.
  75. ' ************************************************
  76. Public Sub ShowPreview(frm As Form)
  77.     ' Make the PictureBoxes have Picture properties
  78.     ' and give them useful color palettes.
  79.     HiddenPict.Picture = HiddenPict.Image
  80.     PreviewPict.Picture = PreviewPict.Image
  81.     HiddenPict.Picture.hPal = frm.Picture.hPal
  82.     PreviewPict.Picture.hPal = frm.Picture.hPal
  83.     HiResPrint frm, HiddenPict, hires_ResizePrinter
  84.     mnuSetScale_Click 1 ' Start at normal scale.
  85.     Show vbModal
  86. End Sub
  87. ' ************************************************
  88. ' Unload if the user presses escape.
  89. ' ************************************************
  90. Private Sub Form_KeyPress(KeyAscii As Integer)
  91.     If KeyAscii = vbKeyEscape Then mnuFileClose_Click
  92. End Sub
  93. Private Sub mnuFileClose_Click()
  94.     Unload Me
  95. End Sub
  96. ' ************************************************
  97. ' Copy the hidden picture to PreviewPict at
  98. ' the appropriate scale.
  99. ' ************************************************
  100. Private Sub mnuSetScale_Click(Index As Integer)
  101. Dim i As Integer
  102. Dim s As Single
  103.     ' Check the selected menu item.
  104.     For i = 0 To 2
  105.         mnuSetScale(i).Checked = (i = Index)
  106.     Next i
  107.     ' Make PreviewPict the right size.
  108.     Select Case Index
  109.         Case 0  ' Large scale.
  110.             s = 1.5
  111.         Case 1  ' Normal scale.
  112.             s = 1#
  113.         Case 2  ' Small scale.
  114.             s = 0.75
  115.     End Select
  116.     PreviewPict.Move 0, 0, _
  117.         s * HiddenPict.Width, s * HiddenPict.Height
  118.     Width = PreviewPict.Width + Width - ScaleWidth
  119.     Height = PreviewPict.Height + Height - ScaleHeight
  120.     ' Copy the image.
  121.     HiddenPict.Picture = HiddenPict.Image
  122.     PreviewPict.Picture = HiddenPict.Picture
  123.     PreviewPict.PaintPicture HiddenPict.Image, _
  124.         0, 0, _
  125.         PreviewPict.ScaleWidth, _
  126.         PreviewPict.ScaleHeight, _
  127.         0, 0, _
  128.         HiddenPict.ScaleWidth, _
  129.         HiddenPict.ScaleHeight, vbSrcCopy
  130. End Sub
  131. Private Sub PreviewPict_Resize()
  132.     Width = PreviewPict.Width + Width - ScaleWidth
  133.     Height = PreviewPict.Height + Height - ScaleHeight
  134. End Sub
  135.